/*挡风玻璃雨刷类*/
public class WindshieldWiper {
	private LeverSense leverSense;   //操纵杆
	private DialSense dialSense;     //刻度盘
	private PowerStatus powerStatus;  //电源状态
	
	//构造函数
	public WindshieldWiper()
	{
		powerStatus = PowerStatus.OFF;
		leverSense = new LeverSense(powerStatus, LeverPosition.STOP);
		dialSense = new DialSense(powerStatus, 1);
	}
	
	//构造带参数的挡风玻璃雨刷类
	public WindshieldWiper(PowerStatus statPower,LeverSense sLever,DialSense sDial)
	{
		powerStatus = statPower;
		leverSense = sLever;
		dialSense = sDial;
	}
	
	//设置操纵杆和刻度盘的位置
	public void SetLeverDial(LeverPosition posLever,int posDial)
	{
		leverSense.SetLeverPosition(posLever);
		dialSense.SetDialPosition(posDial);
	}
	
	//加电
	public void PowerOn()
	{
		powerStatus = PowerStatus.ON;
		leverSense.SetPowerStatus(PowerStatus.ON);
		dialSense.SetPowerStatus(PowerStatus.ON);
	}
	
	//断电
	public void PowerOff()
	{
		powerStatus = PowerStatus.OFF;
		leverSense.SetPowerStatus(PowerStatus.OFF);
		dialSense.SetPowerStatus(PowerStatus.OFF);
	}
	
	//获得雨刷的速度
	public int GetSpeed()
	{
		int nSpeed = 0;
		if( PowerStatus.OFF == powerStatus )
		{
			nSpeed = 0; //断电的状态，速度为零。
			return nSpeed;
		}
		switch(leverSense.GetLeverPosition())
		{
		case STOP:
			nSpeed = 0;	
			break;
		case INTERM:
			int ndp = dialSense.GetDialPosition();
			if(1 == ndp)
				nSpeed = 4;
			else if(2 == ndp)
				nSpeed = 6;
			else
				nSpeed = 12;
			break;
		case LOW:
			nSpeed = 30;	
			break;
		case HIGH:
			nSpeed = 60;	
			break;
		}
		return nSpeed;
	}
}
